SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

create procedure dbo.DnnProduct_UpdateOnlineUser

@UserID 	int,
@PortalID 	int,
@TabID 		int,
@LastActiveDate datetime 

as
BEGIN
	IF EXISTS (SELECT UserID FROM dbo.DnnProduct_UsersOnline WHERE UserID = @UserID and PortalID = @PortalID)
		UPDATE 
			dbo.DnnProduct_UsersOnline
		SET 
			TabID = @TabID,
			LastActiveDate = @LastActiveDate
		WHERE
			UserID = @UserID
			and 
			PortalID = @PortalID
	ELSE
		INSERT INTO
			dbo.DnnProduct_UsersOnline
			(UserID, PortalID, TabID, CreationDate, LastActiveDate) 
		VALUES
			(@UserID, @PortalID, @TabID, GetDate(), @LastActiveDate)

END









GO
